#include"SortCode.h"

void Test()
{
	int arr[] = { 3,1,5,7,0,1,4,346,346,26,72,7,24,5724,62,1,6134,6};
	//BubbleSort(arr, sizeof(arr) / sizeof(arr[0]));
	//Print(arr, sizeof(arr) / sizeof(arr[0]));
	/*InsertSort(arr, sizeof(arr) / sizeof(arr[0]));
	Print(arr, sizeof(arr) / sizeof(arr[0]));*/
	/*ShellSort(arr, sizeof(arr) / sizeof(arr[0]));
	Print(arr, sizeof(arr) / sizeof(arr[0]));*/
	Print(arr, sizeof(arr) / sizeof(arr[0]));
	HeapSort(arr, sizeof(arr) / sizeof(arr[0]));
	Print(arr, sizeof(arr) / sizeof(arr[0]));
}

void Test01()
{
	srand(time(0));
	int N = 100000;
	int* a1 = (int*)malloc(sizeof(int) * N);
	int* a2 = (int*)malloc(sizeof(int) * N);
	int* a3 = (int*)malloc(sizeof(int) * N);
	int* a4 = (int*)malloc(sizeof(int) * N);
	int* a5 = (int*)malloc(sizeof(int) * N);
	int* a6 = (int*)malloc(sizeof(int) * N);
	int* a7 = (int*)malloc(sizeof(int) * N);
	int* a8 = (int*)malloc(sizeof(int) * N);
	int* a9 = (int*)malloc(sizeof(int) * N);
	int* a10 = (int*)malloc(sizeof(int) * N);
	for (int i = 0; i < N; i++)
	{
		a1[i] = rand() + i;
		a2[i] = a1[i];
		a3[i] = a2[i];
		a4[i] = a3[i];
		a5[i] = a4[i];
		a6[i] = a5[i];
		a7[i] = a6[i];
		a8[i] = a7[i];	
		
	}

	int begin1 = clock();
	BubbleSort(a1, N);
	int end1 = clock();
	printf("BubbleSort() :  %d\n", end1-begin1);

	int begin2 = clock();
	InsertSort(a2, N);
	int end2 = clock();
	printf("InsertSort :  %d\n", end2 - begin2);

	int begin3 = clock();
	ShellSort(a3, N);
	int end3 = clock();
	printf("ShellSort :  %d\n", end3 - begin3);

	int begin4 = clock();
	SelectSort(a4, N);
	int end4 = clock();
	printf("SelectSort :  %d\n", end4 - begin4);

	int begin5 = clock();
	HoareQuickSort(a5, 0,N-1);
	int end5 = clock();
	printf("HoareQuickSort :  %d\n", end5 - begin5);

	int begin6 = clock();
	NonRecQsort(a6, 0, N - 1);
	int end6 = clock();
	printf("NonRecQsort :  %d\n", end6 - begin6);

	int begin7 = clock();
	DigHoleQuickSort(a7, 0, N - 1);
	int end7 = clock();
	printf("DigHoleQuickSort :  %d\n", end7 - begin7);

	int begin8 = clock();
	Prev_LastPointerQuickSort(a8, 0, N - 1);
	int end8 = clock();
	printf("Prev_LastPointerQuickSort :  %d\n", end8 - begin8);

	int begin9 = clock();
	HeapSort(a9,N);
	int end9 = clock();
	printf("HeapSort :  %d\n", end9 - begin9);
}
int main()
{
	//Test();
	Test01();
	return 0;
}